﻿
using System;
using System.Collections.Generic;

using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Web.Profile;
using System.Text;

using Gift.DAL;
using Gift.Model;
using Gift.Model.ENUM;

namespace WebSite.admin.order
{
    public partial class OrderComplain : BaseAdmin
    {
        readonly DALOrderCompain theOrderCompain = new DALOrderCompain();
        readonly DALCompain theCompain = new DALCompain();



    protected void Page_Load(object sender, EventArgs e)
    {
       
        if (!base.IsPostBack)
        {
            base.ValidateLoginRule(ERule.CompainList);
            this.BindCompainTypeList();
            this.BindGrid();
        }
    }

     void BindCompainTypeList()
        {
            DataSet ds;
            ds = theCompain.GetList("");
            if (ds != null && ds.Tables.Count > 0)
            {
                this.ddlCompainType.DataTextField = "CompainName";
                this.ddlCompainType.DataValueField = "CompainId";
                this.ddlCompainType.DataSource = ds.Tables[0].DefaultView;
                this.ddlCompainType.DataBind();
                this.ddlCompainType.Items.Insert(0,new ExtAspNet.ListItem("投诉类别...", "-1"));
                this.ddlCompainType.SelectedValue = "-1";
            }
        }


    protected void btnSearch_Click(object sender, EventArgs e)
    {
        this.BindGrid();
    }



    protected void Grid1_PageIndexChange(object sender, ExtAspNet.GridPageEventArgs e)
    {
        Grid1.PageIndex = e.NewPageIndex;
        BindGrid();
    }


    DataTable GetGridData()
    {
        DataSet ds;
        ds = theOrderCompain.GetOrderCompainList(this.txtOrderCode.Text.Trim(), int.Parse(this.ddlCompainType.SelectedItem.Value), int.Parse(this.ddlProcessType.SelectedItem.Value));

        return ds.Tables[0];
    }

    protected void Grid1_Sort(object sender, ExtAspNet.GridSortEventArgs e)
    {

         DataTable table = GetGridData();
            DataView view1 = table.DefaultView;
            view1.Sort = String.Format("{0} {1}", e.SortField, e.SortDirection);
            Grid1.DataSource = view1;
            Grid1.DataBind();
    
    }
    private void BindGrid()
    {
        DataTable table = GetGridData();
        Grid1.DataSource = table;
        Grid1.DataBind();

    }




  
    }
}

